import { request } from '../../request';

// get login log list by page
export function fetchGetLoginLogByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.LoginLog.LoginLogQueryRecord>({
    url: '/log/login/listByPage',
    method: 'post',
    data: params
  });
}

// clear login log by ago
export function fetchClearLoginLog(ago: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | 'ALL') {
  return request({
    url: 'log/login/deleteByAgo',
    method: 'post',
    params: {
      ago
    }
  });
}

// get operate log list by page
export function fetchGetOperateLogByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.OperateLog.OperateLogQueryRecord>({
    url: '/log/operate/listByPage',
    method: 'post',
    data: params
  });
}

// delete operate log by ago
export function fetchClearOperateLog(ago: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | 'ALL') {
  return request({
    url: 'log/operate/deleteByAgo',
    method: 'post',
    params: {
      ago
    }
  });
}

// get upload log list by page
export function fetchGetUploadLogByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.OperateLog.OperateLogQueryRecord>({
    url: '/log/upload/listByPage',
    method: 'post',
    data: params
  });
}

// clear upload log by ago
export function fetchClearUploadLog(ago: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | 'ALL') {
  return request({
    url: 'log/upload/deleteByAgo',
    method: 'post',
    params: {
      ago
    }
  });
}

// 行数据验签
export function validRowSign(tableName: string, rowId: CommonType.IdType) {
  return request({
    url: '/log/rowSign/validSign',
    method: 'post',
    params: {
      tableName,
      rowId
    }
  });
}
